package com.yj.easynavigationbarlibaray;

import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * Created by Sigthp-P-Department on 2018/4/9.
 */

class ViewHelper {


    private View mView;
    private NavigationController.NavigationParams mParams;

    public ViewHelper(Context mContext, int mViewLayoutResId,NavigationController.NavigationParams params) {
        this.mView = LayoutInflater.from(mContext).inflate(mViewLayoutResId, params.mViewGroup, false);
        this.mParams=params;
    }

    public ViewHelper(View mView,NavigationController.NavigationParams params) {
        this.mView=mView;
        this.mParams=params;
    }

    public void addView() {
        if(mParams.mViewGroup == null) {
            ViewGroup viewGroupRoot = (ViewGroup) ((Activity) mParams.mContext).getWindow().getDecorView();
            mParams.mViewGroup = (ViewGroup) viewGroupRoot.getChildAt(0);

        }
        if(mParams.mViewGroup == null){
            return;
        }
        mParams.mView=mView;
        mParams.mViewGroup.addView(mView, 0);
    }
}
